﻿@{
    ViewBag.Title = "ProjectDocumentList";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@model List<DepartmentWork.Model.ProjectDocumentViewModel>
<link href="~/Assets/plugins/bootstrap-treeview/css/bootstrap-treeview.css" rel="stylesheet" />
<script src="~/Assets/plugins/bootstrap-treeview/js/bootstrap-treeview.js"></script>

<script>
    function ShowParent(index) {
        if ($("#treeview li[data-nodeid='" + index + "']").css('display') == 'block')
        {
            $("#treeview li[data-nodeid='" + index + "']").hide(300);
            $("#span_" + index).attr('class', 'icon expand-icon glyphicon glyphicon-plus');
        }
        else
        {
            $("#treeview li[data-nodeid='" + index + "']").show(300);
            $("#span_" + index).attr('class', 'icon expand-icon glyphicon glyphicon-minus');
        }
        
    }
    
    function DelDocument(documentId)
    {
        if (!confirm("请确认是否删除该文档？"))
        {
            return false;
        }
        window.location.href = '@Url.Action("DelDocument","Document",new{area="DevelopArea"})' + '?documentId=' + documentId;
    }


</script>

<div class="page-header">
    <div class="pull-left">
        <ol class="breadcrumb visible-sm visible-md visible-lg">
            <li><a href="@Url.Action("Index","Home",new{area=""})"><i class="icon fa fa-home"></i>主页</a></li>
            <li><a href="@Url.Action("Index","Project",new{area="DevelopArea"})"><i class="fa fa-envelope"></i>开发模块</a></li>
            <li><a href="@Url.Action("ProjectInfo","Project",new{area="DevelopArea",projectId=ViewBag.ProjectId})"><i class="fa fa-envelope"></i>项目详情</a></li>
            <li class="active"><a href="#"><i class="fa fa-envelope"></i>文档</a></li>
        </ol>
    </div>
</div>

<div class="panel">
    <div class="panel-heading bk-bg-primary">
        <h6><i class="fa fa-table red"></i><span class="break"></span>@ViewBag.ProjectName 项目文档</h6>
              @{
                    if (ViewBag.IsDevelopLeader==true)
                    {
                        <div class="panel-actions">
                              <a data-toggle="modal" data-target="#myModal" class="bk-margin-5 btn btn-default  btn-sm" style="background-color: #ECEDF0">&nbsp;&nbsp;上传文档&nbsp;&nbsp;</a>
                        </div>
                    }
                }
    </div>
    <div class="col-lg-12">
    <div class="col-sm-12">
        <label for="treeview"></label>
        <div id="treeview" class="treeview">
            <ul id="ul_user" class="list-group">
@*                <li class="list-group-item node-treeview" data-nodeid="0">
                    <!-- 节点合并样式为 glyphicon-plus 展开样式为： glyphicon-minus-->
                    <span class="icon expand-icon glyphicon glyphicon-plus"></span>
                    <span class="icon node-icon"></span>
                    软件科 一级节点 节点 合并
                    <span class="badge">3 child elements</span>
                </li>*@

                <!-- class中 加 ‘node-selected’ 代表 选中 ，选中后改变样式 style="color:#FFFFFF;background-color:#428bca;"-->
                <li class="list-group-item node-treeview" onclick="ShowParent(1)">
                    <span id="span_1" class="icon expand-icon glyphicon glyphicon-minus"></span>
                    <span class="icon node-icon"></span>
                    需求
                    <span class="badge">文档数量：@this.Model.FindAll(r=>r.DocumentType=="DEVELOP_DOCUMENT_REQUIRE").Count()</span>
                </li>
                @{
                    for (int i = 0; i < this.Model.Count(); i++)
                    {
                        var item = this.Model[i];
                        if (item.DocumentType == "DEVELOP_DOCUMENT_REQUIRE")
                        {
                             <li class="list-group-item node-treeview" data-nodeid="1">
                                <span class="indent"></span>
                                <span class="icon"></span>
                                <span class="icon node-icon"></span>
                                @item.DocumentName
                                <a class="badge" href="~/Home/DownLoadFile?filePath=@item.DocumentFileSaveName&type=Document&fileName=@item.DocumentFileSaveName">下载</a>
                                @{
                                    if (ViewBag.IsDevelopLeader==true)
                                    {
                                        <span class="badge" onclick="DelDocument('@item.DocumentFileId')">删除</span>
                                    }
                                }
                            </li>
                        }
                    }
                }
                
                <li class="list-group-item node-treeview" onclick="ShowParent(2)">
                    <span id="span_2" class="icon expand-icon glyphicon glyphicon-minus"></span>
                    <span class="icon node-icon"></span>
                    设计
                    <span class="badge">文档数量：@this.Model.FindAll(r => r.DocumentType == "DEVELOP_DOCUMENT_DESIGN").Count()</span>
                </li>
                @{
                    for (int i = 0; i < this.Model.Count(); i++)
                    {
                        var item = this.Model[i];
                        if (item.DocumentType == "DEVELOP_DOCUMENT_DESIGN")
                        {
                             <li class="list-group-item node-treeview" data-nodeid="1">
                                <span class="indent"></span>
                                <span class="icon"></span>
                                <span class="icon node-icon"></span>
                                @item.DocumentName
                                                                 <a class="badge" href="~/Home/DownLoadFile?filePath=@item.DocumentFileSaveName&type=Document&fileName=@item.DocumentFileSaveName">下载</a>
                                
                                @{
                            if (ViewBag.IsDevelopLeader == true)
                            {
                                        <span class="badge" onclick="DelDocument('@item.DocumentFileId')">删除</span>
                            }
                                }
                            </li>
                        }
                    }
                }
               
                <li class="list-group-item node-treeview" onclick="ShowParent(3)">
                    <span id="span_3" class="icon expand-icon glyphicon glyphicon-minus"></span>
                    <span class="icon node-icon"></span>
                    数据字典
                    <span class="badge">文档数量：@this.Model.FindAll(r => r.DocumentType == "DEVELOP_DOCUMENT_DATADICTIONARY").Count()</span>
                </li>
                @{
                    for (int i = 0; i < this.Model.Count(); i++)
                    {
                        var item = this.Model[i];
                        if (item.DocumentType == "DEVELOP_DOCUMENT_DATADICTIONARY")
                        {
                             <li class="list-group-item node-treeview" data-nodeid="1">
                                <span class="indent"></span>
                                <span class="icon"></span>
                                <span class="icon node-icon"></span>
                                @item.DocumentName
                                                                 <a class="badge" href="~/Home/DownLoadFile?filePath=@item.DocumentFileSaveName&type=Document&fileName=@item.DocumentFileSaveName">下载</a>
                                @{
                            if (ViewBag.IsDevelopLeader == true)
                            {
                                       <span class="badge" onclick="DelDocument('@item.DocumentFileId')">删除</span>
                            }
                                }
                            </li>
                        }
                    }
                }
                <li class="list-group-item node-treeview" onclick="ShowParent(4)">
                    <span id="span_4" class="icon expand-icon glyphicon glyphicon-minus"></span>
                    <span class="icon node-icon"></span>
                    部署文档
                    <span class="badge">文档数量：@this.Model.FindAll(r => r.DocumentType == "DEVELOP_DOCUMENT_DATADICTIONARY").Count()</span>
                </li>
                @{
                    for (int i = 0; i < this.Model.Count(); i++)
                    {
                        var item = this.Model[i];
                        if (item.DocumentType == "DEVELOP_DOCUMENT_PUBLISH")
                        {
                             <li class="list-group-item node-treeview" data-nodeid="1">
                                <span class="indent"></span>
                                <span class="icon"></span>
                                <span class="icon node-icon"></span>
                                @item.DocumentName
                                                                 <a class="badge" href="~/Home/DownLoadFile?filePath=@item.DocumentFileSaveName&type=Document&fileName=@item.DocumentFileSaveName">下载</a>
                                @{
                            if (ViewBag.IsDevelopLeader == true)
                            {
                                        <span class="badge" onclick="DelDocument('@item.DocumentFileId')">删除</span>
                            }
                                }
                            </li>
                        }
                    }
                }
            </ul>
        </div>
    </div>
</div>
</div>




<!-- 模态框（Modal） -->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet" />
    <link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker-theme.css" rel="stylesheet" />
    <script src="~/Assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script src="~/Assets/plugins/chosen/chosen.jquery.min.js"></script>
    <script src="~/Assets/js/pages/form-elements.js"></script>

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">上传文档：
                </h4>
            </div>
            <form method="POST" enctype="multipart/form-data" action="@Url.Action("CreateDocument", "Document", new { area = "DevelopArea" })">
            <div class="modal-body">
                <div class="row">
                    <input type="hidden" name="hid_ProjectId" value="@ViewBag.ProjectId"/>
                    <label class="col-md-3 control-label" for="text-input">文档名称：</label>
                    <div class="col-md-9">
                        <input id="tb_DocumentName" style="border-color: cornflowerblue" name="tb_DocumentName" class="form-control" placeholder="Text" type="text">
                    </div>
                </div>
                <br />

                <div class="row">
                    <label class="col-md-3 control-label">文档类别：</label>
                    <div class="col-md-9">
                     <select name="select_DocumentType" id="select_DocumentType" class="form-control selectpicker">
                         <option value="DEVELOP_DOCUMENT_REQUIRE">需求</option>
                         <option value="DEVELOP_DOCUMENT_DESIGN">设计</option>
                         <option value="DEVELOP_DOCUMENT_DATADICTIONARY">数据字典</option>
                         <option value="DEVELOP_DOCUMENT_PUBLISH">部署</option>
                       </select>
                    </div>
                </div>

                <br />
                
                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">文档：</label>
                    <div class="col-md-9">
                           <input id="tb_DocumentFile" style="border-color: cornflowerblue" name="tb_DocumentFile" class="form-control" placeholder="Text" type="file">
                    </div>
                </div>
                <br />
              
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    关闭
                </button>
                <input type="submit" class="btn btn-primary"  value="新增"/>
            </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>
